package com.cloudm.technician.ui.modules.cloudm_box.machine_list

import android.os.Bundle
import android.view.MenuItem
import com.cloudm.technician.R
import com.cloudm.technician.extensions.addFragmentToActivity
import com.cloudm.technician.extensions.openActivity
import com.cloudm.technician.ui.base.BaseActivity
import com.cloudm.technician.ui.modules.cloudm_box.machine_history.MachineHistoryActivity

/**
 * 作者: wesley
 * 时间: 2017/12/18
 * 描述: 机器列表界面
 */
class MachineListActivity : BaseActivity() {

    override val optionsMenuEnabled: Boolean
        get() = true

    override val menuRes: Int
        get() = R.menu.menu_machine_list

    override fun handleBundle(bundle: Bundle) {

    }

    override fun initVariables() {

    }

    override fun initViews(savedInstanceState: Bundle?) {
        headerTitle = R.string.machine
        displayHomeAsUpEnabled = true

        val fragment = manager.findFragmentById(
                R.id.common_content) as? MachineListFragment ?: MachineListFragment.newInstance()
        addFragmentToActivity(manager, fragment)
    }

    override fun initListener() {

    }


    override fun onOptionsItemSelected(item: MenuItem?): Boolean {
        return when (item?.itemId) {
            R.id.menu_history -> {
                openActivity(MachineHistoryActivity::class.java, false)
                true
            }

            else -> false
        }
    }


}